1. Field of the Invention
The present invention relates to a data transfer method for transferring data between a processor and a network interface/device such as memory or an output device, or between processes within a computer, and to a memory management system for managing data blocks to be used in the data transfer method.
2. Description of the Background Art
In the conventional OS (Operating System), data structures required for managing devices (including network interfaces, memory such as a hard disk, output device such as a display device, etc.) have been managed by the OS independently for each device. For example, in a case of displaying image data transferred from a network to a display device connected to a computer, data structures for managing a network interface and a display device are different, so that it is necessary to convert the image data from a data structure required for managing the network interface to a data structure required for managing the display device, during transfer of the image data.
Referring now to FIG. 1, a conventional method of data transfer from one device to another device will be described for an exemplary case in which the X server process displays image data transferred from a network to a display device. For details of the X server, see: Oliver Jones, "Introduction to the X Window System", Prentice-Hall, Inc., 1989.
In this case, packets from a network (not shown) are temporarily stored in a buffer 114 on a network interface 113 (path or "step" (a) of FIG. 1), and then transferred by a driver in the OS through a data bus 120 to a data structure (such as mbuf) 116 for managing the network interface which is provided within a kernel space 101 of a main memory 115 (step (b) f FIG. 1).
After an adequate protocol processing is applied by a network protocol processing module in the OS, transfer data are extracted from received packets, and these extracted transfer data are transferred through the data bus 120 to a prescribed data memory region 117 within a user space 102 of the main memory 115 (step (c) of FIG. 1). Here, the data memory region 117 is secured by either the X server or a data transfer destination process such as a client process.
Then, after a proper conversion processing is applied by the X server, the data transferred to the data memory region 117 within the user space 102 are further transferred through the data bus 120 to a data region called frame buffer 118 which is managed by the OS to display images through a display device 119 (step (d) of FIG. 1). Here, the frame buffer 118 is a bit map memory device which is a hardware element for storing image data to be displayed on a display screen.
Finally, image data stored in the frame buffer 118 are read out by a computer hardware (not shown) at an appropriate refresh rate, and transferred to the display device 119, such that the image data transferred via the network are displayed on the display device 119 (step (e) of FIG. 1).
In such a case where data are to be transferred over a plurality of devices, that is, a case of transferring data between a device interface and a user space, frame buffer, or another device interface, it has conventionally been necessary to transfer data more than once, so that there has conventionally been a problem that the data transfer efficiency is poor.
On the other hand, in the conventional OS, data storage structures are different according to types of devices, so that it is sufficient to provide a mutually exclusive control for accesses to the data storage structures by user processes. However, if the data storage structures are shared by more than one process, when a certain process made an access to a data storage structure in order to transfer data to a certain device, this data memory structure would become inaccessible for the other processes even if the accesses by the other processes are for different devices, so that there has conventionally been a problem that the data transfer efficiency is poor in this regard.
Now, there are cases in which a management mechanism called "STREAMS" is used as a data structure required for a device management, that is, a management of data blocks to be used for data transfer. The STREAMS is a management mechanism which has been developed to realize an efficient management of buffers used in processing a network protocol and data exchanges with SVR4 (System V Release 4) network interfaces. For details of a data structure and an operation in the STREAMS, see: Janet I. Egan and Thomas J. Teixeira, "Writing A UNIX Device Driver", 2nd Edition, John Wiley & Sons, inc., 1992.
FIG. 2 illustrates how this conventional STREAMS management mechanism works. As shown in FIG. 2, a top address of a region for storing transfer data is indicated by (db.sub.-- base) and transfer data are to be stored starting from this (db.sub.-- base), so that it is impossible to store transfer data starting from an address different from a top address.
Note that in a case of transferring packets through a network, a packet is often produced by attaching a header at a top of transfer data, so that packets can be produced efficiently if it is possible to store transfer data with some empty region at a top of the secured region and to write a header into this empty region at a time of producing packets. However, as noted above, it has been impossible to store transfer data with some empty region at a top of the region in the conventional STREAMS data structure, so that there has conventionally been a problem of a poor efficiency at a time of producing packets.
In addition, in the conventional STREAMS explained with reference to FIG. 2, a data memory region 124 to be used for storing transfer data is acquired in memory at a time of receiving packets or producing packets to be transmitted, but since this data memory region 124 is to be acquired in memory only after a request is issued, there has conventionally been a problem of a poor efficiency in acquiring this data memory region 124 on a memory.
Similarly, in the conventional STREAMS explained with reference to FIG. 2, data structures called message control blocks (msgb) 122 and data control blocks (datb) 123 are also acquired in memory according to need, but since these data structures are to be acquired in memory only after a request is issued, there has conventionally been a problem of a poor efficiency in acquiring these data structures on a memory.
Now, in the conventional OS, programs are turned into processes at times of their execution, and a management of memory space, etc., has been made in units of processes. For example, a memory management in the OS called UNIX is described in detail in: Maurice J. Bach, "The Design of the UNIX Operating System", Prentice-Hall, inc., 1986.
FIG. 3 illustrates an exemplary mapping between virtual pages and physical pages in a conventional OS such as UNIX. In FIG. 3, a virtual page "a" 304 belonging to a virtual space 301 for a process #1 is mapped into a physical page A 305 in a physical space 302 of an actual memory, while a virtual page "b" 304 belonging to a virtual space 301 for a process #2 is mapped into a physical page B 305 in a physical space 302 of an actual memory, and this mapping between virtual pages and physical pages is fixed in the conventional OS.
FIG. 4 illustrates a state of a page table 303 corresponding to the mapping between the virtual pages and the physical pages of FIG. 3. In the page table 303, a virtual page number (an upper portion of a virtual address) is used as an index, which is to be used for searching a page table entry (PTE) for storing a physical page number, etc. In a state shown in FIG. 4, the page table 303 indicates that the physical page A corresponds to the virtual page "a" and the physical page B corresponds to the virtual page "b".
FIG. 5 shows how a virtual address 316 is converted into a physical address 317 in a conventional computer. For details of a conversion from a virtual address to a physical address in microprocessors of 20 Intel, Corp. (Santa Clara, Calif., U.S.A.), see: Ross P. Nelson "Microsoft's 80386/80486 Programming Guide", 2nd Edition, Microsoft Press (Redmond, Wash., U.S.A.), 1991.
FIG. 5 indicates that the upper part of a virtual address is a virtual page number and the lower part of a virtual address is an offset address. Similarly, the upper part of a physical address is a physical page number and the lower part of a physical address is an offset address. In this case, the virtual address can be translated into the physical address by translating the virtual page number into the physical page number by a translation device 314, while using the same offset.
For this translation from the virtual page number to the physical page number, the page table 303 of FIG. 4 is to be used, but in order to make the translation processing faster, those page table entries (PTEs) which were accessed before are stored in a cache called a TLB (Translation Lookaside Buffer) 313.
Here, a method of data transfer between processes in such a conventional OS will be described for an exemplary case of UNIX.
In UNIX, a virtual space is allocated to each process, and in a case of switching the execution from one process to another process, an access protection for data stored in a device such as a memory has been realized by switching virtual spaces. Consequently, a transfer source process cannot transfer data directly to a data region managed by a transfer destination process, and a transfer destination process cannot make an access directly to transfer data in a data region managed by a transfer source process.
For this reason, it has conventionally been necessary to transfer data from one process to another process as follows. Namely, first, the transfer source process transfers the transfer data to a data region managed by the OS. Then, the transfer destination process transfers the transfer data to a data region managed by the transfer destination process itself.
As a consequence, in a case of transferring data between processes by this conventional data transfer method, the transfer data must be transferred at least twice, actually four times in a case of the data transfer via a processor, so that there has conventionally been a problem of a poor data transfer efficiency.
In addition, in the conventional data transfer method, a processing by which packets are transferred from a network to a receiving process and a processing by which a user program transmits data to a network are also plagued by poor efficiencies.
In the former processing of packet reception, when packets are received by a network interface, the received packets are transferred from the network interface board to a network buffer which is a region in a main memory that is managed by the OS. Then, these received packets stored in the network buffer are transferred to a processor for carrying out an error check calculation such as a checksum calculation in order to check whether there is any transfer error. Then, those received packets for which a transfer error is not detected are transferred via the processor to a receiving buffer managed by the transfer destination process. In this case, for the packets received by the network interface to get transferred to the transfer destination process, the data must be transferred four times, so that the data transfer efficiency has been poor.
Similarly, in the latter processing of packet transmission, in order for the user process to transmit data to the network, the user process transfers data to be transferred to a network buffer managed by the OS via a processor first. Then the transfer data are transferred to the processor in order to calculate necessary error detection data for enabling a receiving host to check whether there is any transfer error. Then, the transfer packets to which the error detection data and packet headers are attached are transferred to a network interface. In this case, for the user process to transmit packets to the network, data must be transferred four times, so that the data transfer efficiency has been poor.
Thus the conventional computer system has a problem in that a data transfer efficiency has been poor in a case of the data transfer between a device interface and a user space, a frame buffer, or another device interface, as it is necessary to repeat the data transfer many times between the both sides.
Moreover, in a case of transferring data between processes, a data transfer efficiency has been also poor conventionally, as the data must be transferred at least twice.
Furthermore, in a case of transferring data from a data region owned by the user process to a data region managed by the OS via a processor, a data transfer efficiency has been even poorer conventionally, as the data must be transferred four times.
Also, in a case of extracting the transfer data from the received packets transferred from the network, and transferring the extracted transfer data to a data region managed by the transfer destination process, a data transfer efficiency has been just as poor conventionally, as the data must be transferred four times.
In addition, in a case of producing transmission packets from data owned by the user process and transferring them to the network, a data transfer efficiency has been just as poor conventionally, as the data must be transferred four times.